package org.example.hansp.reflection.class_.get_the_class;

import org.junit.jupiter.api.Test;
@SuppressWarnings({"all"})
public class GetTheClassMethod {
   @Test
    public void method1() {
       Class clazz=Cat.class;
       System.out.println(clazz);
       System.out.println(clazz.hashCode());
   }
   @Test
    public void method2() throws ClassNotFoundException {
       Class clazz=Class.forName("org.example.hansp.reflection.class_.get_the_class.Cat");
       System.out.println(clazz);
       System.out.println(clazz.hashCode());
   }
   @Test
    public void method3()   {
       Class clazz=new Cat().getClass();
       System.out.println(clazz);
       System.out.println(clazz.hashCode());
   }
   @Test
    public void method4() throws ClassNotFoundException {
       //1.先得到类加载器对象
      ClassLoader classLoader=new Cat().getClass().getClassLoader();
       Class clazz = classLoader.loadClass("org.example.hansp.reflection.class_.get_the_class.Cat");
       System.out.println(clazz);
       System.out.println(clazz.hashCode());
   }

   @Test
    public void basicDataType(){
       Class<Integer> integerClass = int.class;
       Class<Double> doubleClass = double.class;
       Class<Float> floatClass = float.class;
       Class<Long> longClass = long.class;
       Class<Character> characterClass = char.class;
       Class<Boolean> booleanClass = boolean.class;


       Class<Integer> integerClass1 = Integer.TYPE;
       Class<Character> characterClass1 = Character.TYPE;
       System.out.println(integerClass.hashCode());
       System.out.println(integerClass1.hashCode());
       System.out.println(integerClass.equals(integerClass1));
       System.out.println(characterClass==characterClass1);
   }
}
